<?php
/**
 * This module processes short links
 * Module looks for the structure element named :client with the parameter 'clients'
 * and then redirects user using LinkGen library
 *
 * Eg.  example.com/est/diil -> (int) 1234 -> link( 1234 )
 */

class reduceActions extends sfActions{  public function executeIndex(sfRequest $request)  {    $structure = Doctrine::getTable('Structure')->findAll();    $element   = 0;        foreach($structure as $node) {      if($node->getType() == 'lang' && $node->getSlug() == $request->getParameter('lang')) {        $children = $node->getNode()->getDescendants();                foreach($children as $child) {          if($child->getSlug() == $request->getParameter('client') && $child->getParameter() == 'clients') {            $element = $child->getId();          }        }                break;      }    }        if($element) {      $this->redirect(LinkGen::getInstance(LinkGen::STRUCTURE)->link($element));    } else throw new Exception(sprintf('Client structure "%s" was not found', $request->getParameter('client')));  }};